﻿@model ScrumTracker.Models.Product
@{
    ViewBag.Title = @Model.Name;
    Layout = "~/Views/Shared/_Layout5.cshtml";
}
@if (false)
{
    <script src="../../Scripts/jquery-1.5.1-vsdoc.js" type="text/javascript"></script>
}
<div id="tabs" style="margin: 0; overflow: hidden;">
    <ul>
        <li>
            <a href="#stories">Stories</a></li>
    </ul>
    <div id="stories">
        <div style="text-align: right;">
            <a href="@Url.Action("New", "Stories", new { ProductId = Model.ProductId })" class="button">Add Story</a>
        </div>
        <hr />
        @{
            var grid = new WebGrid(Model.Stories.Where(s => s.SprintId == null).OrderByDescending(s => s.Priority).ThenBy(s => s.Effort), canSort: false, canPage: false);
            @grid.GetHtml(
            columns:
                grid.Columns(
                grid.Column(format: @<a href="@Url.Action("Get", "Stories", new { @id = item.IssueId })">Story #@item.IssueId</a>),
                    grid.Column("Description"),
                    grid.Column("Priority"),
                    grid.Column("Effort"),
                    grid.Column("EstimatedHours"),
                    grid.Column("RemainingHours")
                ),
                tableStyle: "table-issues",
                headerStyle: "ui-widget-header"
            )
        }
        <table border="1" cellspacing="0" cellpadding="0" style="width: auto; display: none;">
            <tr>
                <td>
                    Handle
                </td>
                <td>
                    Expand
                </td>
                <td>
                    Story
                </td>
                <td>
                    Priority
                </td>
                <td>
                    Effort
                </td>
                <td>
                    Hours
                </td>
                <td>
                    Comments
                </td>
                <td>
                    Attachments
                </td>
                <td>
                    Actions
                </td>
            </tr>
            @foreach (var story in Model.Stories.Where(s => s.SprintId == null).OrderByDescending(s => s.Priority).ThenBy(s => s.Effort))
            { 
                <tr issue_id="@story.IssueId">
                    <td class="draggable" style="cursor: move;">
                        DRAG
                    </td>
                    <td class="expandable">
                        EXPAND
                    </td>
                    <td>
                        @story.Description
                    </td>
                    <td>
                        @story.Priority
                    </td>
                    <td>
                        @story.Effort
                    </td>
                    <td>
                        @story.Tasks.Sum(a => a.EstimatedHours)
                    </td>
                    <td>
                        3
                    </td>
                    <td>
                        @story.Attachments.Count
                    </td>
                    <td style="white-space: nowrap;">
                        <a class="button" href="@Url.Action("Get", "Stories", new { @id = story.IssueId })">Edit</a> <a class="button" href="#">Delete</a>
                    </td>
                </tr>
            }
        </table>
    </div>
</div>
<div style="clear: both;">
</div>
